#!/usr/bin/python3

# bash
#  cat doc.txt| sed "s/ /\n/g" | sort | uniq -c
import sys
if __name__ == "__main__":
    d = {}
    for w in sys.stdin:
        w = w.strip()
        if w in d:
            d[w] += 1
        else:
            d[w] = 1

    for key in d:
        print(key, d[key])
